# !/usr/bin/env python
# -*-coding:utf-8 -*-

"""
# Author     ：skyTree
# version    ：python 3.11
# Description：fastapi启动和关闭时的监听事件
"""
from fastapi import FastAPI

from database.mysql import register_mysql


def startup_event(app: FastAPI):
    """
    启动事件
    :return:
    """

    @app.on_event("startup")
    async def startup():
        await register_mysql(app)
        print("Fastapi Project Start Running......")


def shutdown_event(app: FastAPI):
    """
    关闭事件
    :return:
    """

    @app.on_event("shutdown")
    async def shutdown():
        print("Fastapi Project End Running......")
